/*
 * adc.c
 *
 *  Created on: 16/04/2009
 *      Author: Marcelo
 */

#include "include/adc.h"

static AdcChannel ChannelList[10];

void addAdcChannel(AdcChannel *Channel)
{
  ChannelList[Channel->Channel] = *Channel;
}

void enableADC(BYTE Channel)
{
  //writeByte(__ADMUX__, ChannelList[Channel].VccRef | ((ChannelList[Channel].LeftAdjustResult) ? 0x20 : 0x00) | ChannelList[Channel].Channel);
  //writeByte(__ADCSRA__, __ADEN | __ADIE | ChannelList[Channel].DivFactor);
  if (ChannelList[Channel].Handler)
    {
      switch (Channel)
      case 1:
        {
          //addHandler(HWND_ADC0, ChannelList[Channel].Handler);
          break;
        }
    }
}

void reconfigureADC()
{
  writeByte(__ADCSRA__, __ADSC | __ADIE);
  ADCSRA |= (1<<ADSC)|(1<<ADIE);
}

void onADC0Data(void (*Handler))
{
  if (Handler)
    addHandler(HWND_ADC0, Handler);
}

